package com.test.nnooolwdeaer.activity_fragment_wooden;

import static android.view.View.VISIBLE;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.test.nnooolwdeaer.R;
import com.test.nnooolwdeaer.activity_fragment_wooden.base_wooden.BaseActivity_wooden;
import com.test.nnooolwdeaer.activity_fragment_wooden.base_wooden.BaseApplication_wooden;
import com.test.nnooolwdeaer.constant_wooden.Constant_wooden;
import com.test.nnooolwdeaer.dialog_wooden.DropDialog_wooden;
import com.test.nnooolwdeaer.dialog_wooden.LogoutDialog_wooden;
import com.test.nnooolwdeaer.util_wooden.http_wooden.HttpManager_wooden;
import com.test.nnooolwdeaer.view_wooden.widget_wooden.TitleView_wooden;

public class SettingActivity_wooden extends BaseActivity_wooden {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting_wooden);

        try {

            boolean showDropBtn = getIntent().getBooleanExtra("showDropBtn",false);

            TitleView_wooden titleView = findViewById(R.id.setting_titleview);
            TextView versionTv = findViewById(R.id.setting_tv_version);
            Button logoutBtn = findViewById(R.id.setting_btn_logout);
            View deleteDataView = findViewById(R.id.setting_view_delete_data);

            titleView.getBackIb_wooden().setOnClickListener(v -> {
                HttpManager_wooden.getInstance_wooden().saveUserBuriedPoint("SETTING_BACK_CLICK");
                onBackPressed();
            });

            logoutBtn.setOnClickListener(view -> {
                HttpManager_wooden.getInstance_wooden().saveUserBuriedPoint("SETTING_LOGOUT_CLICK");
                new LogoutDialog_wooden(this).show();
            });

            versionTv.setText(getString(R.string.version_2, BaseApplication_wooden.getApplication().versionName()));

            if (showDropBtn){
                deleteDataView.setVisibility(VISIBLE);
                deleteDataView.setOnClickListener(view -> {
                    new DropDialog_wooden(this).show();
                });
            }

        }catch (Exception e){
            if (Constant_wooden.Debug) e.printStackTrace();
        }

    }

}